﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
         isELIgnored="false"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
    <head>
        <title>单证性质</title>
        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/appmonitor/zTreeStyle/zTreeStyle.css" type="text/css">
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery.ztree-2.6.js"></script>
        <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" />
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/zcms/zDialog.js"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/zcms/zDrag.js"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/demoTools.js"></script>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <SCRIPT LANGUAGE="JavaScript">
            var zTree1;
            var setting;
      
            setting = {
                //            checkable : true,
                isSimpleData: true,
                treeNodeKey: "id",
                treeNodeParentKey: "pId",
                fontCss: setFont,
		

                callback: {
                    beforeExpand: function(){return false;},
                    beforeCollapse: function(){return false;},
                    beforeClick: zTreeOnBeforeClick,
                    click: zTreeClick
                }
		
            };

            $(document).ready(function(){
                zNodes=<s:property value="jsonDataString" escape="false"/>;

                reloadTree();
                expandAll(true);
                $("body").bind("mousedown", 
                function(event){
                    if (!(event.target.id == "menuBtn" || event.target.id == "DropdownMenuBackground" || $(event.target).parents("#DropdownMenuBackground").length>0)) {
                        hideMenu();
                    }
                });
            });

            function showMenu() {
                var cityObj = $("#citySel");
                var cityOffset = $("#citySel").offset();
                $("#DropdownMenuBackground").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
		
            }
            function hideMenu() {
                $("#DropdownMenuBackground").fadeOut("fast");
            }

            function setFont(treeId, treeNode) {
                if (treeNode && treeNode.isParent) {
                    return {color: "blue"};
                } else {
                    return null;
                }
            }
	
            function expandAll(expandSign) {
                zTree1.expandAll(expandSign);
            }

            var addCount = 1;



            function zTreeOnBeforeClick(treeId, treeNode) {
                var check = (treeNode && !treeNode.isParent);
                if (!check) alert("只能选择详细性质");
                return check;
            }
            function reloadTree() {
           
                hideMenu();
                zTree1 = $("#dropdownMenu").zTree(setting, clone(zNodes));
            }	
            function zTreeClick(event, treeId, treeNode) {
                if (treeNode) {
                  
                    var cityObj = $("#citySel");
                    var groupid=$("#groupid");
                 
                    cityObj.attr("value", treeNode.name);
                    
                    groupid.attr("value",treeNode.id);
                    hideMenu();
                   
                }
            }
            function addgroup(treeNode)
            {
                var groupid=$("#groupid").val();
            
                if(groupid==null)
                {
                    alert("请先性质！");
                        
                }
                else{
                    return groupid;
                }
               
  
            }


        </SCRIPT>
    </head>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"
          style="border: 1px solid #dddddd; background:#FFFFFF;">
        <s:hidden id="groupid" ></s:hidden>
        <TABLE width="230" height="100%" border=0 align="center" cellpadding="0" cellspacing="0" class="tb1">
            <TR>

                <TD width="50%" height="45" align=center valign=top bgcolor="#FFFFFF">
                    <div class="zTreeDemoBackground">
                        <br/>
                        分组：<input id="citySel" type="text" readonly value="" style="width:80px;"/>
                        <a id="menuBtn" href="#" onClick="showMenu(); return false;">选择</a>
                    </div>	
                </TD>

            </TR>

        </TABLE>

        <div id="DropdownMenuBackground" style="display:none; position:absolute; height:200px; width:150px; background-color:white;border:1px solid;overflow-y:auto;overflow-x:auto;">
            <ul id="dropdownMenu" class="tree"></ul>
        </div>
    </body>
</html>
